<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import = "com.sinodata.bsm.common.vo.*" %>
<%@ page import = "com.sinodata.bsm.center.util.spring.SpringContextHolder" %>
<%@ page import = "com.sinodata.bsm.center.service.config.PortalService" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ include file="../../include/taglib.jsp"%>
<%
	String confId= request.getParameter("confId");
	PortalService portalService = SpringContextHolder.getBean(PortalService.class);
	PageConf  conf = portalService.findPageConfById(Long.parseLong(confId));
	String params = conf.getParams();
	if(params==null){
	    params = "";
	}
	
%>
<html>
  <head>
    <title>notifystatisticssparam</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<%@ include file="../../include/common.jsp"%>
  	<%@ include file="../../include/form.jsp"%>
  	<script type="text/javascript">
  	var pageId = '<%=confId%>';
  	$(document).ready(function() {
  		  var params = '<%=params%>';
  		  var obj = jQuery.parseJSON(params);
  		  var inputs = $(":input");
  		  if(obj!=null){
  		  for(var i=0; i<inputs.length; i++){
  		  	var key = $(inputs[i]).attr("name");
  		  	if(obj[key]!=null){
  		  		$(inputs[i]).val(obj[key])
  		  	}
  		  }
  		  }
  		  function add(){
  		
  			 $.ajax({
				   	type: "POST", 
				   	url : "/bsm/portlet/portal!saveConf.action", // 请求的action
				 	data: $("#portalParamForm").serialize(), //传的参数
				   	dataType: 'json',
				 
				   	success: function(data){ //结果
				   	   reloadPage();
					   closewin();
				   	}
			});
		  }
  		  $.formValidator.initConfig({formid:"portalParamForm"
          ,onerror:function(msg){}
          ,onsuccess:function(){
        	  		add();
          			return false;
          }
  
          });
       $("#cmpTitle").formValidator({onshow:"请输入组件标题 长度(1-32)",onfocus:"请输入组件标题  长度(1-32)",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"})
	  .functionValidator({
			    fun:function(val,elem){
			    	    if(val.replace(/[^\x00-\xff]/g, "xx").length > 32){
			    	        return "长度超出最大范围";
			    	    }
			    	    return true;
				}
	  });
  
	});
  function reloadPage()
  {
  		var win = getTopWin(window).currentWin["show-jsp-params"];
  		win.reloadPage();
  }
  function closewin(){
	   getTopWin(window).closejBox("show-jsp-params");
  }
</script>
</head>
    <body class="padding-8">
    	<form action="" id="portalParamForm" name="portalParamForm" method="post">
    	<input type="hidden" name="confId" value="<%=confId %>">
    		<table  class="table_eidt">
    			<tr>
	    			<td class="td_left" width="100px"><span class="span_alert">*</span>组件标题</td>
	    			<td class="td_right"><input type="text" name="cmpTitle" id="cmpTitle" class="input_text" value="<%=conf.getTitle() %>">
	    			</td>
    			</tr>
    			<tr>
	    			<td class="td_left"><span class="span_alert">*</span>时间区间</td>
	    			<td class="td_right">
	    			<select name="PARAM_time" id="PARAM_time">
	    				<option value="0" selected>全部</option>
	    				<option value="1">今天</option>
	    				<option value="2">本周</option>
	    				<option value="3">本月</option>
	    			</select>
	    			</td>
	    		</tr>
    		</table>
    		<div align="center" style="margin-top:5px;">
	    		<input type="submit" id="button" name="button" value="保存" class="btn-4">
	    		<input type="reset" class="btn-4">
	    		<input type="button" value="取消" onclick="closewin();" class="btn-4">
    		</div>
    		
    	</form>
  </body>
</html>
    